package com.phs.main.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.phs.main.vo.OwnerVO;
import com.phs.main.web.po.SysUsers;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author Trent
 * @since 2020-07-07
 */
@Repository
public interface SysUsersMapper extends BaseMapper<SysUsers> {
	@Select("select id, name, age, id_num, tel, address, unit, house_name, time" +
			" from (select s.user_ID as id," +
			"             user_name as name," +
			"             age," +
			"             id_num," +
			"             tel," +
			"             address," +
			"             house_unit as unit," +
			"             house_name ," +
			"             start_time as time" +
			"      from sys_users s" +
			"               left join property_information p" +
			"                         on s.user_ID = p.user_ID) as sp" +
			" where sp.id" +
			"          in (" +
			"          select r.user_ID" +
			"          from sys_users_roles r," +
			"               sys_users s" +
			"          where r.user_ID = s.user_ID" +
			"            and s.locked <> 1" +
			"            and r.role_ID not in (1, 2, 4)" +
			"      )")
	List<OwnerVO> getOwner();

}
